package com.example;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * 使用Jsoup.connect()访问页面获取org.jsoup.Connection，再设置请求头，再用Jsoup.parse()进行解析
 */
public class Demo3 {
    public static void main(String[] args) {
        URL url = null;
        try {
            // 获取连接
            Connection connect = Jsoup.connect("https://k.sina.cn/article_1683472727_6457c157020014cbg.html?from=news&subch=onews");
            // 解析页面
            Document document = connect.get();
            Element root = document.getElementsByClass("j_main_art").first();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("【完成】");
    }
}
